using FastNet.Core.Attributes;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;

namespace FastNet.Core.Base;

[ApiController,JwtAuthorize]
public class BaseController<IService> : ControllerBase
{
    protected IService Service;
    public BaseController(IService service)
    {
        Service = service;
    }
    protected JsonResult JsonNormal(object data, JsonSerializerSettings? serializerSettings = null, bool formateDate = true)
    {
        serializerSettings = serializerSettings ?? new JsonSerializerSettings();
        serializerSettings.ContractResolver = null;
        if (formateDate)
        {
            serializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
        }
        return Json(data, serializerSettings);
    }
    protected JsonResult Json(object data, JsonSerializerSettings? serializerSettings = null)
    {
        return new JsonResult(data, serializerSettings);
    }
}
